#include "cstdio"
//今年的第几天
//1.空间换时间
//int main(){
//    int year,mon,day;
//    int mday[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
//    int totalDay[13]={0};
//    for (int mon = 2; mon <=12 ; ++mon) {
//        totalDay[mon] = totalDay[mon-1]+mday[mon-1];
//    }
//    while(scanf("%d%d%d",&year,&mon,&day)!=EOF){
//        //如果是闰年
//        bool isLeap = year%400==0 || year%100!=0 && year%4==0;
//        if(isLeap== true&& mon >=3){
//            printf("%d\n",totalDay[mon]+day+1);
//        } else{
//            printf("%d\n",totalDay[mon]+day);
//        }
//    }
//    return 0;
//}
//2.遍历 年的某一天
int main(){
    int year,n;
    int mday[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
    while (scanf("%d%d",&year,&n)!=EOF){
        int mon = 1;
        int day = 1;
        for (int i = 0; i < n-1; ++i) {
            //nextDay
            bool isLeap = year%400==0 || year%100!=0 && year%4==0;
            if(isLeap){
                mday[2]=29;
            } else{
                mday[2]=28;
            }
            ++day;
            if(day>mday[mon]){
                ++mon;
                day = 1;
                if(mon>12){
                    mon=1;
                    ++year;
                }
            }
        }
        printf("%4d-%2d-%2d\n",year,mon,day);
    }
}
